package com.emo.wowoblog.utils;

import cn.hutool.extra.mail.MailUtil;

import java.util.Random;

public class EmailUtils {

    /**
     * description:生成邮箱验证码
     */
    public static String creatEmailCode() {
        StringBuilder sb = new StringBuilder();
        Random rand = new Random();
        for (int i = 0; i < 6; i++) {
            sb.append(rand.nextInt(10));
        }
        return sb.toString();
    }

    /**
     * 给某个邮箱发送验证码
     * @param toEmail
     * @param validateCode
     */
    public static void sendEmailValidateCode(String toEmail, String validateCode) {
        MailUtil.send(toEmail, "欢迎注册窝窝技术论坛", validateCode, false);
    }

}
